﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace Adams.Admin.DataAccess.Security
{
    public static class Forgot
    {
        public static Adams.Admin.DataTransfer.Security.Forgot.UserInfo GetUserInfo(string email)
        {
            var data = new Adams.Admin.DataTransfer.Security.Forgot.UserInfo();

            using (SqlDataReader dr = DB.RunDataReader(@"
SELECT *
FROM Console.Users
WHERE Email = @Email
", CommandType.Text,
                DB.CreateParameter("@Email", email, SqlDbType.VarChar, 50)))
            {
                if (dr.HasRows)
                {
                    dr.Read();
                    data.IsActive = dr["IsActive"].DbBool();
                    data.Exists = true;
                }
                else
                {
                    data.Exists = false;
                }
            }

            return data;
        }
    }
}
